
package cn.edu.xmu.restfuldemo.model;
import cn.edu.xmu.restfuldemo.model.Orders;
import  cn.edu.xmu.restfuldemo.model.OrderItem;

import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
public class OrderRetVo {

    private Integer id;
    private String orderSn;
    private Integer pid;
    private Integer orderType;
    private Integer state;
    private Integer subState;
    private Date gmtCreate;
    private Date gmtModified;
    private Date confirmTime;
    private Integer originPrice;
    private Integer discountPrice;
    private Integer freightPrice;
    private Integer rebateNum;
    private String message;
    private Integer regionId;
    private String address;
    private String mobile;
    private String consignee;
    private Integer couponId;
    private Integer grouponId;
    private Integer presaleId;
    private String shipmentSn;
    private List<OrderItemRetVo> orderItems;

    public OrderRetVo(Orders order){
        this.id=order.getId();
        this.address=order.getAddress();
        this.consignee=order.getConsignee();
        this.confirmTime=order.getConfirmTime();
        this.couponId=order.getCouponId();
        this.discountPrice=order.getDiscountPrice();
        this.freightPrice=order.getFreightPrice();
        this.gmtCreate=order.getGmtCreate();
        this.gmtModified=order.getGmtModified();
        this.grouponId=order.getGrouponId();
        this.message=order.getMessage();
        this.mobile=order.getMobile();
        this.orderSn=order.getOrderSn();
        this.orderType=order.getOrderType();

        if(null!=order.getOrderItems()){
            List<OrderItemRetVo> orderItemRetVos= new ArrayList<>(order.getOrderItems().size());
            for (OrderItem orderItem:order.getOrderItems()){
                orderItemRetVos.add(new OrderItemRetVo(orderItem));
            }
            this.orderItems= orderItemRetVos;
        }
    }
}
